// document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
//     // 通过下面这个API隐藏底部导航栏
//     WeixinJSBridge.call('hideToolbar');
// });
// WeixinJSBridge.invoke('getNetworkType',{},function(e){
//     // 在这里拿到e.err_msg，这里面就包含了所有的网络类型
//     alert(e.err_msg);
//  });
// document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
//     WeixinJSBridge.call('hideToolbar');
//     WeixinJSBridge.call('hideOptionMenu');
// });
// wx.hideMenuItems({
//     menuList: ["menuItem:share:timeline", "menuItem:copyUrl", "menuItem:share:appMessage", "menuItem:share:qq", "menuItem:share:weiboApp", "menuItem:favorite", "menuItem:share:facebook", "menuItem:share:QZone", "menuItem:editTag", "menuItem:delete", "menuItem:copyUrl", "menuItem:originPage", "menuItem:readMode", "menuItem:openWithQQBrowser", "menuItem:openWithSafari", "menuItem:share:email", "menuItem:share:brand"] // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮
// });
//1 十个考题的布局
var questionBank = [
    '<div class="quesNumber">1/7</div><div class="quesImg"><img src="./img/rubric/imgOne.png" alt=""></div><div class="quesTitle"><img src="./img/rubric/quesOne.png" alt=""></div><ul class="check"><li class="checkItem" onclick="nextQuestion(this,true)">荷兰</li><li class="checkItem" onclick="nextQuestion(this)">意大利</li><li class="checkItem" onclick="nextQuestion(this)">埃及</li><li class="checkItem" onclick="nextQuestion(this)">智利</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg" style="top:4rem"><img src="./img/rubric/imgTwo.png" alt="" style="width:11rem;height:8rem;display:block"></div><div class="quesTitle" style="top:13rem"><img src="./img/rubric/quesTwo.png" alt=""></div><ul class="check" style="top:18rem"><li class="checkItem" onclick="nextQuestion(this)">3</li><li class="checkItem" onclick="nextQuestion(this)">4</li><li class="checkItem" onclick="nextQuestion(this,true)">5</li><li class="checkItem" onclick="nextQuestion(this)">6</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg" style="top:4rem"><img src="./img/rubric/imgThree.png" alt=""></div><div class="quesTitle"><img src="./img/rubric/quesThree.png" alt=""></div><ul class="check"><li class="checkItem" onclick="nextQuestion(this)">10月6日</li><li class="checkItem" onclick="nextQuestion(this,true)">10月7日</li><li class="checkItem" onclick="nextQuestion(this)">10月8日</li><li class="checkItem" onclick="nextQuestion(this)">10月9日</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg"><img src="./img/rubric/imgFour.png" alt=""></div><div class="quesTitle"><img src="./img/rubric/quesFour.png" alt=""></div><ul class="check" style="top:17rem"><li class="checkItem" onclick="nextQuestion(this)">德国</li><li class="checkItem" onclick="nextQuestion(this,true)">巴西</li><li class="checkItem" onclick="nextQuestion(this)">阿根廷</li><li class="checkItem" onclick="nextQuestion(this)">俄罗斯</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg"><img src="./img/rubric/imgFive.png" alt=""></div><div class="quesTitle" style="top:12rem"><img src="./img/rubric/quesFive.png" alt=""></div><ul class="check" style="top:17rem"><li class="checkItem" onclick="nextQuestion(this,true)">西班牙</li><li class="checkItem" onclick="nextQuestion(this)">荷兰</li><li class="checkItem" onclick="nextQuestion(this)">阿根廷</li><li class="checkItem" onclick="nextQuestion(this)">希腊</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg" style="top:4rem"><img src="./img/rubric/imgSix.png" alt=""></div><div class="quesTitle" style="top:12rem"><img src="./img/rubric/quesSix.png" alt=""></div><ul class="check" style="top:17rem"><li class="checkItem" onclick="nextQuestion(this)">罗纳尔多</li><li class="checkItem" onclick="nextQuestion(this,true)">克洛泽</li><li class="checkItem" onclick="nextQuestion(this)">贝利</li><li class="checkItem" onclick="nextQuestion(this)">穆勒</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg"><img src="./img/rubric/imgSeven.png" alt=""></div><div class="quesTitle" style="top:13rem"><img src="./img/rubric/quesSeven.png" alt=""></div><ul class="check" style="top:18rem"><li class="checkItem" onclick="nextQuestion(this)">替补</li><li class="checkItem" onclick="nextQuestion(this)">教练</li><li class="checkItem" onclick="nextQuestion(this)">退役球员</li><li class="checkItem" onclick="nextQuestion(this,true)">球迷</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg"><img src="./img/rubric/imgEight.png" alt=""></div><div class="quesTitle" style="top:13rem"><img src="./img/rubric/quesEight.png" alt=""></div><ul class="check" style="top:18rem"><li class="checkItem" onclick="nextQuestion(this)">1990</li><li class="checkItem" onclick="nextQuestion(this)">1994</li><li class="checkItem" onclick="nextQuestion(this,true)">1998</li><li class="checkItem" onclick="nextQuestion(this)">2002</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg"><img src="./img/rubric/imgNine.png" alt=""></div><div class="quesTitle" style="top:13.5rem"><img src="./img/rubric/quesNine.png" alt=""></div><ul class="check" style="top:18.5rem"><li class="checkItem" onclick="nextQuestion(this,true)">巴西</li><li class="checkItem" onclick="nextQuestion(this)">荷兰</li><li class="checkItem" onclick="nextQuestion(this)">阿根廷</li><li class="checkItem" onclick="nextQuestion(this)">法国</li></ul>',
    '<div class="quesNumber">1/7</div><div class="quesImg" style="top:5rem"><img src="./img/rubric/imgTen.png" alt=""></div><div class="quesTitle" style="top:11rem"><img src="./img/rubric/quesTen.png" alt=""></div><ul class="check" style="top:16rem"><li class="checkItem" onclick="nextQuestion(this)">熊</li><li class="checkItem" onclick="nextQuestion(this)">狐狸</li><li class="checkItem" onclick="nextQuestion(this)">马</li><li class="checkItem" onclick="nextQuestion(this,true)">狼</li></ul>',
];

//2 设置考题数
var total = 7;

//3 当考题的长度大于总考题数的时候
while( questionBank.length > total){
    //4 将quesetionBank进行随机删除
    questionBank.splice(Math.floor(Math.random()*(questionBank.length - 1)),1)
}
//5 设置当前考题的下标
var currentIndex = 0;

//6 设置当前得分
var score = 0;


//7 把第一题渲染到页面去
$(".backg").html(questionBank[currentIndex]);
$('.quesNumber').html((currentIndex + 1)+'/'+total);

//8 当点击选项的时候执行
function nextQuestion(t,flag){
    $(t).addClass('active');
    setTimeout(function(){
        if(flag){
            score++;
        }
        currentIndex++;
        if(currentIndex >= questionBank.length){
            //当下标等于题目长度减一的时候根据不同得分实现跳转到结果页面
            if(score <= 2){
                window.location.href = "./result_3.html";
            }else if(score == 3 || score == 4){
                window.location.href = "./result_2.html";
            }else if(score == 5 || score == 6){
                window.location.href = "./result_4.html";
            }else{
                window.location.href = "./result_1.html";
            }
        }else{
            $(".backg").html(questionBank[currentIndex]);
            $('.quesNumber').html((currentIndex+1)+'/'+total);
        }
    },200);

}